﻿namespace qiniu_class
{
    public class QiniuBase
    {
        public string AccessKey;
        public string Bucket;
        public string Domain;
        public string SecretKey;

        public QiniuBase()
        {
            //string isTravisTest = System.Environment.GetEnvironmentVariable("isTravisTest");
            //if (!string.IsNullOrEmpty(isTravisTest) && isTravisTest.Equals("true"))
            //{
            //    this.AccessKey = System.Environment.GetEnvironmentVariable("QINIU_ACCESS_KEY");
            //    this.SecretKey = System.Environment.GetEnvironmentVariable("QINIU_SECRET_KEY");
            //    this.Bucket = System.Environment.GetEnvironmentVariable("QINIU_TEST_BUCKET");
            //    this.Domain = System.Environment.GetEnvironmentVariable("QINIU_TEST_DOMAIN");
            //    this.LocalFile = System.Environment.GetEnvironmentVariable("QINIU_LOCAL_FILE");
            //}
            //else
            //{
            AccessKey = "nJSPKHkXLPXGZuajkBfT8om-5mZIZRe54MEwdIuY";
            SecretKey = "nn-9JWMoAdCtanmNyiWE9T-TSsPeyIKvK7PpO1h5";
            Bucket = "incool-east";
            Domain = "oyf7ysubw.bkt.clouddn.com";
            //}
        }


        public bool TryGetUploadConfig(IQiniuConfig config)
        {
            var result = false;
            if (config.TryGetConfig())
            {
                AccessKey = config.AccessKey;
                Bucket = config.Bucket;
                Domain = config.Domain;
                SecretKey = config.SecretKey;
                result = true;
            }
            return result;
        }
    }

    public interface IQiniuConfig
    {
        string AccessKey { get; }
        string Bucket { get; }
        string Domain { get; }
        string SecretKey { get; }
        bool TryGetConfig();
    }
}